/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package estg.dae.projecto.bank.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author Marco
 */
@Entity
@Table(name = "Accounts",
uniqueConstraints = {@UniqueConstraint(columnNames = "nib")})
public class Account implements Serializable {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private long id;
    @ManyToOne(fetch=FetchType.LAZY)
    private Client client;
    private String nib;
    private long number;
    private int agency;
    private double accountingBalance;
    private double availableBalance;
    private double overBalance;
    @OneToMany(mappedBy = "account", fetch=FetchType.LAZY)
    private Collection<AccountMovement> movements;
    
    //@OneToMany(mappedBy = "account")
    //private List<Card> cards;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public double getAccountingBalance() {
        return accountingBalance;
    }

    public void setAccountingBalance(double accountingBalance) {
        this.accountingBalance = accountingBalance;
    }

    public double getAvailableBalance() {
        return availableBalance;
    }

    public void setAvailableBalance(double availableBalance) {
        this.availableBalance = availableBalance;
    }

    public Client getClient() {
        return client;
    }

    public void setClient(Client client) {
        this.client = client;
    }

    public String getNib() {
        return nib;
    }

    public void setNib(String nib) {
        this.nib = nib;
    }

    public int getAgency() {
        return agency;
    }

    public void setAgency(int agency) {
        this.agency = agency;
    }

    public long getNumber() {
        return number;
    }

    public void setNumber(long number) {
        this.number = number;
    }

    public double getOverBalance() {
        return overBalance;
    }

    public void setOverBalance(double overBalance) {
        this.overBalance = overBalance;
    }

    public Collection<AccountMovement> getMovements() {
        return movements;
    }

    public void setMovements(Collection<AccountMovement> movements) {
        this.movements = movements;
    }
    
}
